package com.krautzlabs;


import android.app.Activity;
import android.os.Bundle;
import android.view.Display;
import android.view.Window;
import android.view.WindowManager;

public class WarGame extends Activity {//  implements OnTouchListener {
    /** Called when the activity is first created. */
	
	
	private MapView _mapView; 
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
        Display display = getWindowManager().getDefaultDisplay(); 
		int width = display.getWidth();
		int height = display.getHeight();
		//start main loop
		//Main main = new Main(this);
		//main.start();
		
		//the view now starts the model, hands the canvas off to the main loop
		_mapView = new MapView(this, width, height);
		
		setContentView(_mapView);
		
    }
/*
    static final int NONE = 0;
	static final int ONE_FINGER_DRAG = 1;
	static final int TWO_FINGERS_DRAG = 2;
	int mode = NONE;
 
	PointF firstFinger;
	float lastScrolling;
	float distBetweenFingers;
	float lastZooming;
	
    public boolean onTouch(View arg0, MotionEvent event) {
    	switch (event.getAction() & MotionEvent.ACTION_MASK) {
		case MotionEvent.ACTION_DOWN: // Start gesture
			firstFinger = new PointF(event.getX(), event.getY());
			mode = ONE_FINGER_DRAG;
			break;
		case MotionEvent.ACTION_UP: 
		case MotionEvent.ACTION_POINTER_UP:
			//When the gesture ends, a thread is created to give inertia to the scrolling and zoom 
			Timer t = new Timer();
				t.schedule(new TimerTask() {
					@Override
					public void run() {
						while(Math.abs(lastScrolling)>1f || Math.abs(lastZooming-1)<1.01){ 
						lastScrolling*=.8;
						scroll(lastScrolling);
						lastZooming+=(1-lastZooming)*.2;
						zoom(lastZooming);
						mySimpleXYPlot.setDomainBoundaries(minXY.x, maxXY.x, BoundaryMode.AUTO);
						try {
							mySimpleXYPlot.postRedraw();
						} catch (InterruptedException e) {
							e.printStackTrace();
						}
						// the thread lives until the scrolling and zooming are imperceptible
					}
					}
				}, 0);
 
		case MotionEvent.ACTION_POINTER_DOWN: // second finger
			distBetweenFingers = spacing(event);
			// the distance check is done to avoid false alarms
			if (distBetweenFingers > 5f) {
				mode = TWO_FINGERS_DRAG;
			}
			break;
		case MotionEvent.ACTION_MOVE:
			if (mode == ONE_FINGER_DRAG) {
				PointF oldFirstFinger=firstFinger;
				firstFinger=new PointF(event.getX(), event.getY());
				lastScrolling=oldFirstFinger.x-firstFinger.x;
				scroll(lastScrolling);
				lastZooming=(firstFinger.y-oldFirstFinger.y)/mySimpleXYPlot.getHeight();
				if (lastZooming<0)
					lastZooming=1/(1-lastZooming);
				else
					lastZooming+=1;
				zoom(lastZooming);
				mySimpleXYPlot.setDomainBoundaries(minXY.x, maxXY.x, BoundaryMode.AUTO);
				mySimpleXYPlot.redraw();
 
			} else if (mode == TWO_FINGERS_DRAG) {
				float oldDist =distBetweenFingers; 
				distBetweenFingers=spacing(event);
				lastZooming=oldDist/distBetweenFingers;
				zoom(lastZooming);
				mySimpleXYPlot.setDomainBoundaries(minXY.x, maxXY.x, BoundaryMode.AUTO);
				mySimpleXYPlot.redraw();
			}
			break;
		}
		return true;
	}
 
	private void zoom(float scale) {
		float domainSpan = maxXY.x	- minXY.x;
		float domainMidPoint = maxXY.x		- domainSpan / 2.0f;
		float offset = domainSpan * scale / 2.0f;
		minXY.x=domainMidPoint- offset;
		maxXY.x=domainMidPoint+offset;
	}
 
	private void scroll(float pan) {
		float domainSpan = maxXY.x	- minXY.x;
		float step = domainSpan / mySimpleXYPlot.getWidth();
		float offset = pan * step;
		minXY.x+= offset;
		maxXY.x+= offset;
	}
 
	private float spacing(MotionEvent event) {
		float x = event.getX(0) - event.getX(1);
		float y = event.getY(0) - event.getY(1);
		return FloatMath.sqrt(x * x + y * y);
	}*/
}